package com.cn.zpark;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Date;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: ServletDemo02
 * @Description:
 * @author: RZS
 * @date: 2022/4/18  15:22
 */
@WebServlet("/sd2.do")
public class ServletDemo02 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取session对象
        HttpSession session = request.getSession();
        // 绑定数据到session域
        session.setAttribute("obj", "今天好冷");
        // 修改session域绑定数据
        session.setAttribute("obj", new Date());

        // 容易出session域绑定数据
        session.removeAttribute("obj");

    }
}
